#include "SMPPBindResp.hpp"

using namespace smpp::pdu;

BindResp::BindResp(const Header &nHeader,const CoctetString &nSystemId,
const SrInterfaceVersion *nSrInterfaceVersion):
Header(nHeader),_SystemId(nSystemId),_SrInterfaceVersion(0){
	if(nSrInterfaceVersion)
		_SrInterfaceVersion = 
			new SrInterfaceVersion(*nSrInterfaceVersion);
}

BindResp::BindResp(const BindResp &nBindResp):
Header(nBindResp),_SystemId(nBindResp.getSystemId()),_SrInterfaceVersion(0){
	if(nBindResp.getSrInterfaceVersion())
		_SrInterfaceVersion = 
			new SrInterfaceVersion(*nBindResp.getSrInterfaceVersion());
}

BindResp::~BindResp(){
	if(_SrInterfaceVersion)
		delete _SrInterfaceVersion;
}

void BindResp::setSystemId(const CoctetString &nSystemId){
	_SystemId = nSystemId;
}

const CoctetString &BindResp::getSystemId() const{
	return _SystemId;
}

void BindResp::setScInterfaceVersion(
	const SrInterfaceVersion *nSrInterfaceVersion){
	if(_SrInterfaceVersion){
		delete _SrInterfaceVersion;
		_SrInterfaceVersion = 0;
	}
	if(nSrInterfaceVersion)
		_SrInterfaceVersion = new SrInterfaceVersion(*nSrInterfaceVersion);
}

const SrInterfaceVersion *BindResp::getSrInterfaceVersion() const{
	return _SrInterfaceVersion;
}

void BindResp::calcCommandLength(){
	_CommandLength = 16 + _SystemId.size();
	if(_SrInterfaceVersion)
		_CommandLength += 5;
}
